package com.tom.service.impl;

import com.tom.dao.DemoDao;
import com.tom.entity.Demo;
import com.tom.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
@Slf4j
public class DemoServiceImpl implements DemoService {

    @Resource
    private DemoDao demoDao;


    @Override
    public int add(Demo demo) {
        Demo demo1 = demoDao.save(demo);
        log.info("id:{}",demo1.getId());
        return Objects.nonNull(demo1)?1:0;
    }

    @Override
    public Demo query(Long id) {
        return demoDao.findById(id).orElse(null);
    }
}
